{template header}



<div class="container">

<ol class="breadcrumb">
  <li><a href="{SITE_URL}">首页</a></li>
  <li><a href="{tsUrl('article')}">文档</a></li>
  <li><a href="{tsUrl('article','show',array('id'=>$strArticle['articleid']))}">{$strArticle['title']}</a></li>
  <li class="active">修改文档</li>
</ol>


<div class="panel panel-default">
  <div class="panel-body">


<div class="row">
<div class="col-md-2"></div>
<div class="col-md-8">


<form  id='add' method="POST" action="{SITE_URL}index.php?app=article&ac=edit&ts=do"  enctype="multipart/form-data">

  <div class="form-group">
    <label>标题：</label>
    <input name="title" type="text" class="form-control" value="{$strArticle['title']}" placeholder="可留空，除非发外链">
  </div>
{if $arrCate}  
  <div class="form-group">
    <label>分组：</label>
    
<select class="form-control" id="groupid" name="groupid">
    {if $GLOBALS['TS_USER']['isadmin']=='1'}
    <option value="0">广播</option>
    {/if}
{loop $arrGroup $key $item}
<option value="{$item['groupid']}" {if $item['groupid']==$strArticle['groupid']}selected{/if}>{$item['groupname']}</option>
{/loop}
</select>
	
  </div>
{/if}

    <div class="form-group" style="display: none" id="urlform">
        <label>外链  <a class="btn btn-default" style="height: 20px;padding-top: 1px" onclick="showcontent()">切换内容</a></label>
        <input id="url" name="url" type="text" class="form-control" >
    </div>


  <div class="form-group" id="contentform">
    <label>内容：<a class="btn btn-default" style="height: 20px;padding-top: 1px" onclick="showurl()">切换外链</a></label>
      <div id="tseditor">{$strArticle['content']}</div>

      <div style="display: none;">
          <textarea  id='content' name="content">{$strArticle['content']}</textarea>
      </div>

  </div>


    <div class="form-group">
    <label>标签：</label>
    <input name="tag" type="text" class="form-control" value="{$strArticle['tag']}">
  </div>
<!--
   <div class="form-group">
    <label>封面图片：</label>
	
	{if $strArticle['photo']}
       <p>
	<img src="{php echo tsXimg($strArticle['photo'],'article',180,140,$strArticle['path'],'1')}" />
       </p>
	{/if}
    <input name="photo" type="file">
  </div>
-->
<input type="hidden" name="token" value="{$_SESSION['token']}" />
<input type="hidden" name="articleid" value="{$strArticle['articleid']}" />
<button class="btn btn-success" type="submit">发布文档</button>
    {if $GLOBALS['TS_USER']['isadmin']=='1'}
    <div class="fr">
        <label>设为公告</label>
        <input name="isnotice" type="checkbox" value="1" {if $strArticle['isnotice']==1}checked{/if}/>
    </div>

    {/if}
</form>


</div>
<div class="col-md-2"></div>
</div>



</div>
</div>
</div>
<!--
<script>

    var E = window.wangEditor
    var editor = new E('#weditor')
    editor.customConfig.uploadImgShowBase64 = true
    editor.customConfig.menus = [
        'head',
        'bold',
        'italic',
        'underline',
        'image',  // 插入图片
        'table',  // 表格
        'video',  // 插入视频
    ]

    editor.create()



    $('#add').on('submit', function(e) {
        e.preventDefault();
        var articleid = $('#articleid').val();
        var title = $('#title').val();
        var groupid = $('#groupid').val();
        var gaiyao = $.trim($('#gaiyao').val());
        var tag = $('#tag').val();
        var photo = $.trim($('#photo').val());
        var content = editor.txt.html();


        $.ajax({
            type: "POST",
            dataType: "json",
            url: "{SITE_URL}index.php?app=article&ac=edit&ts=do",
            data: {title:title,groupid:groupid,gaiyao:gaiyao,tag:tag,photo:photo,content:content},
            success: function(data){
                if (data.status == 0) {
                    alert(data.info);
                    return  false;
                } else {
                    window.location.href = data.url;
                }

            }
        });
    })
</script>-->

<script>

    $(function(){
        $('#add').on('submit', function(e) {
            var content  = $('#content').val();
            var url  = $('#url').val();
            if (url==''&&content == '<p><br></p>') {
                bootbox.alert('内容不能为空');
                return false;
            }
        });
    });

    function showurl(){
        $('#urlform').show();
        $('#contentform').hide();
    }

    function showcontent(){
        $('#urlform').hide();
        $('#contentform').show();
    }


</script>
{php doAction('tseditor')}
{template footer}